﻿using Ct.StudentProject.Myself;
using CtCommon.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
using Ct.StudentProject.Data;

namespace Ct.StudentProject.Web
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            student stu = new student(userName.Text, Name.Text, IDNumber.Text, Password.Text);
            string jsonText = JsonConvert.SerializeObject(stu);
            //  MessageBox.Show(jsonText);

            Response.Write("<script>alert('删除成功!')</script>");
            student user = jsonText.JSONDeserialize<student>();

            try
            {

                string msg = string.Empty;
                Deliver del = new Deliver();

                bool isvaild = false;//del.VerifyAndDeliver(user, out msg);

                if (isvaild)
                {
                    Response.Write("<script>alert('"+msg+"')</script>");
                }
                else
                {
                    msg = string.Empty;
                    StudentDatabase db = new Ct.StudentProject.Data.StudentDatabase();
                    if (db.InsertStudent(user, out msg) == true)
                    {
                        //  MessageBox.Show("ID为" + msg);
                        Response.Write("<script>alert(' ID为：" + msg + "')</script>");
                    }
                }

            }
            catch
            {

            }
        }

    }
}